import React, { Component } from 'react'
import { connect } from "react-redux"
import { bindActionCreators } from "redux"
import { actions, getUser } from "../../store/modules/register"
import "./register.css"
class Register extends Component {
    render() {
        let { user: { phone, password, nickname }, register: { changeUser,reqRegister },history } = this.props
        return (
            <div className="register">
                {/* <img src="" alt /> */}
                <ul>
                    <li>手机号：<input type="text" value={phone} onChange={(e) => changeUser("phone", e.target.value)} /></li>
                    <li>昵称：<input type="text" value={nickname} onChange={(e) => changeUser("nickname", e.target.value)} /></li>
                    <li>密码：<input type="text" value={password} onChange={(e) => changeUser("password", e.target.value)} /></li>
                </ul>
                <input type="button" value="注册"  onClick={()=>reqRegister(history)}/>
            </div>


        )
    }

}
let mapStateToProps = (state) => ({
    user: getUser(state),
});
let mapDispatchToProps = (dispatch) => ({
    register: bindActionCreators(actions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(Register)